<template>
	<view class="content">
		<view class="title">
			收货地址
		</view>
		<view class="box1">
			<view class="name">
				<uni-icons class="icon" type="home-filled" size="20" color="rgba(79, 79, 79, 1)"></uni-icons>
				{{userInfo.nickname}}
			</view>
			<view class="mob">{{userInfo.mobile}}</view>
			<view class="addr">{{userInfo.addr}}</view>
		</view>
		<view class="title">
			所购商品
		</view>
		<view class="box2">
			<image :src="detail.pic && detail.pic[0]" mode="aspectFill"></image>
			<view>
				<view class="name">{{detail.name}}</view>
				<view class="jf">
					<view>鸭鸭卡{{detail.source}}</view>
					<view>x 1</view>
				</view>
			</view>
		</view>
		<view class="footer">
			<view class="hj">合计： <text>{{detail.source}}鸭鸭卡</text></view>
			<view class="submit" @click="submit">提交订单</view>
		</view>
	</view>
</template>

<script>
	import {
		getAction,
		postAction
	} from '../../../common/request'
	export default {
		data() {
			return {
				detail: {},
				userInfo: {}
			}
		},
		onLoad(option) {
			getAction('/goods/show', {
				id: option.id
			}).then(res => {
				this.detail = res.data
			})
			this.getUserInfo()
		},
		methods: {
			getUserInfo() {
				getAction('/user').then(res => {
					this.userInfo = res.data
				})
			},
			submit() {
				uni.showLoading({
					mask: true
				})
				postAction('goods/order', {
					id: this.detail.id
				}).then(res => {
					wx.hideLoading()
					if (res.code === 0) {
						uni.showToast({
							title: '提交成功',
							mask: true
						})
						setTimeout(() => {

							uni.navigateBack({
								delta: 1
							})
						}, 1000)
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.content {
		padding: 30rpx;
		padding-bottom: 100rpx;
		color: #2B2B2B;
	}

	.title {

		font-size: 28rpx;
		line-height: 36rpx;
		margin-bottom: 30rpx;
	}

	.box1 {
		min-height: 166rpx;
		background: #F5F5F5;
		border-radius: 10rpx 10rpx 10rpx 10rpx;
		padding-top: 24rpx;
		padding-left: 78rpx;
		padding-bottom: 24rpx;
		padding-right: 24rpx;
		margin-bottom: 40rpx;

		>view {
			margin-bottom: 8rpx;
		}

		.name {
			line-height: 40rpx;

			.icon {
				line-height: 10rpx;
				vertical-align: middle;
				margin-left: -48rpx;
				margin-right: 8rpx;
			}
		}

		.mob {}

		.addr {}
	}

	.box2 {
		min-height: 230rpx;
		background: #F5F5F5;
		border-radius: 10rpx 10rpx 10rpx 10rpx;
		padding: 20rpx;
		display: flex;

		>image {
			width: 160rpx;
			height: 190rpx;
			border-radius: 10rpx;
		}

		>view {
			width: calc(100% - 160rpx);
			position: relative;
			padding: 20rpx;
			padding-bottom: 50rpx;

			.name {
				font-size: 28rpx;
				line-height: 36rpx;
			}

			.jf {
				position: absolute;
				left: 20rpx;
				bottom: 10rpx;
				right: 20rpx;
				font-size: 28rpx;
				line-height: 36rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
			}
		}
	}

	.footer {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		height: 100rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		line-height: 100rpx;
		box-shadow: 0px 0px 3px rgba(212, 212, 212, 1.0);

		.hj {

			font-size: 40rpx;
			padding-left: 40rpx;
			color: #FF5035;

			text {
				color: rgba(43, 43, 43, 1);
			}
		}

		.submit {
			width: 346rpx;
			height: 100rpx;
			background: #FF5035;
			border-radius: 0rpx 0rpx 0rpx 0rpx;
			opacity: 1;
			color: #FFF;
			text-align: center;
			font-size: 32rpx;

		}
	}
</style>